package com.nanhai.buddhist.college.module.study.dal.mysql.subjectconfig;

import java.util.*;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.module.study.dal.dataobject.subjectconfig.StudySubjectConfigDO;
import org.apache.ibatis.annotations.Mapper;
import com.nanhai.buddhist.college.module.study.controller.admin.subjectconfig.vo.*;

/**
 * 课程管理-配置 Mapper
 *
 * @author xqenzo@163.com
 */
@Mapper
public interface StudySubjectConfigMapper extends BaseMapperX<StudySubjectConfigDO> {

    default PageResult<StudySubjectConfigDO> selectPage(StudySubjectConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StudySubjectConfigDO>()
                .likeIfPresent(StudySubjectConfigDO::getName, reqVO.getName())
                .eqIfPresent(StudySubjectConfigDO::getStudySubjectId, reqVO.getStudySubjectId())
                .eqIfPresent(StudySubjectConfigDO::getSubjectDuration, reqVO.getSubjectDuration())
                .eqIfPresent(StudySubjectConfigDO::getBookIds, reqVO.getBookIds())
                .eqIfPresent(StudySubjectConfigDO::getSubjectType, reqVO.getSubjectType())
                .eqIfPresent(StudySubjectConfigDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StudySubjectConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudySubjectConfigDO::getCreateTime));
    }

    default List<StudySubjectConfigDO> selectList(StudySubjectConfigExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<StudySubjectConfigDO>()
                .likeIfPresent(StudySubjectConfigDO::getName, reqVO.getName())
                .eqIfPresent(StudySubjectConfigDO::getStudySubjectId, reqVO.getStudySubjectId())
                .eqIfPresent(StudySubjectConfigDO::getSubjectDuration, reqVO.getSubjectDuration())
                .eqIfPresent(StudySubjectConfigDO::getBookIds, reqVO.getBookIds())
                .eqIfPresent(StudySubjectConfigDO::getSubjectType, reqVO.getSubjectType())
                .eqIfPresent(StudySubjectConfigDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StudySubjectConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudySubjectConfigDO::getCreateTime));
    }

}
